# @Time : 2024-10-22 15:31
# @Author : Fioman 
# @Phone : 13149920693
# 十进制转换为二进制,8进制,16进制
# 然后是二进制,8进制,16进制转换为10进制
nums = 100
binVal = bin(nums)

print(f"binVal: {binVal},type(binVal) = {type(binVal)}")  # 0b1100100 <class 'str'>
octVal = oct(nums)
print(f"octVal: {octVal},type(octVal) = {type(octVal)}")  # 0o144,type(octVal) = <class 'str'>
hexVal = hex(nums)
print(f"hexVal: {hexVal},type(hexVal) = {type(hexVal)}")  # 0x64 <class 'str'>
# 返回的结果都是字符串
numInt = int(octVal, 8)
print(f"numInt: {numInt},type(numInt) = {type(numInt)}")  # 100 <class 'int'>
numInt = int(hexVal, 16)
print(f"numInt: {numInt},type(numInt) = {type(numInt)}")
numInt = int(binVal, 2)
print(f"numInt: {numInt},type(numInt) = {type(numInt)}")
numInt = int("100", 16)  # 这样也行,以为紫瑶传入的是字符串就可以,不一定带前缀
print(f"numInt: {numInt},type(numInt) = {type(numInt)}")
